package com.xls.dormitoryservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xls.dormitoryservice.entity.Department;
import com.xls.dormitoryservice.mapper.DepartmentMapper;
import com.xls.dormitoryservice.service.DepartmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xls
 * @since 2021-03-23
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public List<Department> departmentList() {
        return departmentMapper.selectList(new QueryWrapper<Department>().eq("pid", 0));
    }

    @Override
    public List<Department> majorList() {
        return departmentMapper.selectList(new QueryWrapper<Department>().ne("pid", 0));
    }

    @Override
    public List<Department> majorListById(String id) {
        return departmentMapper.selectList(new QueryWrapper<Department>().eq("pid", id));
    }

    @Override
    public Department department(String id) {
        return departmentMapper.selectById(id);
    }

    @Override
    public Department major(String id) {
        return departmentMapper.selectById(id);
    }
}
